#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "zero.h"
#include "japi.h"

int main(int argc, char *argv[])
{
    //Declaring variables.
    FILE* fp;
    int array_size;
    int zero_crossings;
    float *array_ptr;

    //Open the file in read mode.
	fp = fopen(argv[1], "r");

    //Check if the file opened successfully.
    if (fp == NULL)   /* if unsuccesful */
    {

        //Message if unsuccessful
		printf("Could not open the input file \n\n");

		//Pause then exit
		system("PAUSE");


		/*GUI SHOULD INITIALISE HERE TO ENTER THE FILE BEFOR PROCEEDING!!!*/

	}

	//1. Calling a function to determine the number of rows in the file
	array_size= number_of_rows(fp);

	//Calloc used to create array.
    array_ptr = (float *) calloc(array_size, sizeof(float));

	//2. Calling a function to fill the array
	// Abate's function will go here

	//3.Calling a function to count zero crossings
    zero_crossings = counter(array_size, array_ptr);

    //4.Calling a function to determine and display the results
    determine_result(zero_crossings);
    /*This function will need to be integrated with the GUI, not sure
    how yet!!*/

    system("PAUSE");
    return 0;

}
